package linc.cool.framework.protocol.http;

import com.alibaba.fastjson.JSONObject;
import linc.cool.framework.Invocation;
import linc.cool.framework.URL;

/**
 * @author yqlin
 * @date 2022/3/11 4:44 上午
 * @description
 */
public class HttpClient {
    public static String send(String hostname, Integer port, Invocation invocation) {
        return com.mzlion.easyokhttp.HttpClient
                .textBody("http://" + hostname + ":" + port)
                .json(JSONObject.toJSONString(invocation))
                .charset("utf8")
                .asString();
    }

    public static String send(URL url, Invocation invocation) {
        return send(url.getHostname(), url.getPort(), invocation);
    }
}
